﻿$(function () {
    var pagebtn = $("#getMorePage");
    var item_ul = $("#common-item");
    pagebtn.click(function (a) {
        a && a.preventDefault();
        var nextpage = $(this).attr('page'), pageParams = $(this).attr('param');

        $.ajax({ type: "POST", url: pageParams, data: { page: nextpage }, dataType: "json", beforeSend: function () {
            pagebtn.addClass("non").html("加载中&hellip;")
        }, success: function (b) {
            b.items.forEach(function (item) {
                var nstartdate = new Date(item.NStartDate);
                var nenddate = new Date(item.NEndDate);

                var d = "<li>";
                if (item.NContentType == "Href") {
                    d += "<a class='tbox' href='" + item.NContent + "'>";
                } else {
                    d += "<a class='tbox' href='/phone/news?userid=" + mid + "&nid=" + item.NId + "'>";
                }
                d += "<div>";
                d += "<img class='timg' src='" + item.NSPicUrl + "'/>";
                d += "</div>";
                d += "<div>";
                d += "<p>"

                if (time < nstartdate || time > nenddate) {
                    d += "<span style='color:Red;'>【已过期】</span>";
                }

                d += item.NTitle + "</p>";
                d += "<p><img src='/Content/Images/WeChat/time.png'/>" + item.NCreateDate + "</p>";
                d += "</div></a></li>";

                item_ul.append(d);
            });

            nextpage = parseInt(nextpage) + 1;
            pagebtn.attr("page", nextpage);
            nextpage * 10 < b.pagecount ? pagebtn.removeClass('non').html('加载更多&hellip;') : pagebtn.addClass('non').html('没有更多&hellip;').unbind("click")
        }, error: function () { }
        });
    });
});